@extends('layouts.app')
@include('vendor.ueditor.assets')
@section('js')
    <script type="text/javascript">
    </script>
    <!-- 实例化编辑器 -->
    <script type="text/javascript">
        var ue = UE.getEditor('container');
        ue.ready(function () {
            ue.execCommand('serverparam', '_token', '{{ csrf_token() }}'); // 设置 CSRF token.
        });
    </script>
@endsection
@section('content')
    <div class="container">
        <div class="row">
            <div class="col">

                @include('layouts.errors')
                <h4>{{__('create_post')}}</h4>
                <div class="card">
                    <form class="card-body" action="{{route('posts.store')}}" method="post"
                        enctype="multipart/form-data">
                        {{csrf_field()}}
                        <input type="text" hidden id="user_id" name="user_id" value="{{Auth::user()->id}}">
                        <div class="form-group">
                            <label for="title">标题:</label>
                            <input class="form-control" type="text" name="title" id="title" value="{{old('title')}}">
                        </div>
                        <div class="form-group">
                            <label for="category_id">分类</label>
                            <select class="form-control category" name="category_id">
                                <option disabled>请选择分类...</option>
                                @foreach($categories as $category)
                                    <option value="{{$category->id}}">{{$category->name}}</option>
                                @endforeach
                            </select>
                        </div>


                        <div class="form-group">
                            <label for="image">图片:</label>
                            <input class="form-control" type="file" name="image" id="image">
                        </div>


                        <div class="form-group">
                            <label for="content">内容:</label>
                            <script id="container" name="content" class="" type="text/plain">{!! old('content') !!}</script>
                        </div>

                        <div class="form-group">
                            <button class="btn btn-primary" type="submit">提交</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
@endsection
